/*
 * Copyright (c) 2020 Fraunhofer FOKUS and others. All rights reserved.
 *
 * See the NOTICE file(s) distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contact: mosaic@fokus.fraunhofer.de
 */
package org.eclipse.mosaic.interactions.vehicle;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.eclipse.mosaic.lib.objects.vehicle.CarlaVehicleData;
import org.eclipse.mosaic.rti.api.Interaction;

import java.util.List;

import static org.apache.commons.lang3.builder.ToStringStyle.SHORT_PREFIX_STYLE;

public class CarlaVehicleUpdates extends Interaction {

    private final List<CarlaVehicleRegistration> spawnedActors;

    private final List<String> removedActors;

    private final List<CarlaVehicleData> updateActors;

    public CarlaVehicleUpdates(long time, List<CarlaVehicleRegistration> spawnedActors, List<String> removedActors, List<CarlaVehicleData> updateActors) {
        super(time);
        this.spawnedActors = spawnedActors;
        this.removedActors = removedActors;
        this.updateActors = updateActors;
    }

    public List<CarlaVehicleRegistration> getSpawnedActors() {
        return spawnedActors;
    }

    public List<String> getRemovedActors() {
        return removedActors;
    }

    public List<CarlaVehicleData> getUpdateActors() {
        return updateActors;
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(5, 71)
                .append(spawnedActors)
                .append(removedActors)
                .append(updateActors)
                .toHashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (obj == this) {
            return true;
        }
        if (obj.getClass() != getClass()) {
            return false;
        }

        CarlaVehicleUpdates other = (CarlaVehicleUpdates) obj;
        return new EqualsBuilder()
                .append(this.spawnedActors, other.spawnedActors)
                .append(this.removedActors, other.removedActors)
                .append(this.updateActors, other.updateActors)
                .isEquals();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, SHORT_PREFIX_STYLE)
                .appendSuper(super.toString())
                .append("spawnedActors", spawnedActors)
                .append("removedActors", removedActors)
                .append("updateActors", updateActors)
                .toString();
    }
}
